﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ChangePassword : System.Web.UI.Page
{
    ApplicantMethord AM = new ApplicantMethord();
    string UrlPath = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            UrlPath = Request.RawUrl.Substring(Request.RawUrl.LastIndexOf("/") + 1, Request.AppRelativeCurrentExecutionFilePath.Length - 2);
            if (Request.QueryString["ID"].ToString() != "")
            {
                UrlPath += "?ID=" + Request.QueryString["ID"].ToString();
            }
        }
        catch (Exception ex)
        {
        }
        try
        {
            Session["PageCurrent"] = UrlPath;

            if (Session["User"] != null)
            {
                txtUser.Text = Session["User"].ToString();
            }
            else
            {
                Response.Redirect("LoginApplicant.aspx");
            }
            if (!IsPostBack)
            {
                LoadData(txtUser.Text);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("LoginApplicant.aspx");
        }
    }
    public void LoadData(string _User)
    {

    }
    protected void btnChagepassword_Click(object sender, EventArgs e)
    {
        if (txtNewPassword.Text == txtPasswordConfirm.Text)
        {
            bool Result = AM.CheckLoginApplicant(txtUser.Text, txtPassword.Text);
            if (Result)
            {
                int check = AM.ChangepasswordApplicant(txtUser.Text, txtNewPassword.Text);
                if (check > 0)
                {
                    Response.Write("<script type='text/javascript'>alert('Change password successful');window.location = 'Home.aspx';</script> ");
                }
                else
                {
                    lblError.Text = "Change password Unsuccessful.";
                }
            }
            else
            {
                lblError.Text = "My Password invalid.";
            }
        }
        else
        {
            lblError.Text = "Password confirm invalid.";
        }
    }
}